﻿#define  _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAXSIZE 25
#define DEFAULT_SIZE 4
#define INS_SZ 2
//行李编号 行李航班 姓名 身份证号 行李状态
//001 UC8866 张里 510199909090002 到达
typedef struct PeoInfo
{
	char bagNum[MAXSIZE];//行李编号
	char bagFlight[MAXSIZE];//行李航班
	char name[MAXSIZE];//姓名
	char idNum[MAXSIZE];//身份证号
	char condition[MAXSIZE];//行李状态
}PeoInfo;

typedef struct Baggage
{
	PeoInfo data[DEFAULT_SIZE];
	int sz;
}Baggage;


void InitBaggage(Baggage* pc)
{
	pc->sz = 0;
	memset(pc->data, 0, sizeof(pc->data));
	//1
	strcpy(pc->data[pc->sz].bagFlight,"001");
	strcpy(pc->data[pc->sz].bagNum, "UC8866");
	strcpy(pc->data[pc->sz].name, "张里");
	strcpy(pc->data[pc->sz].idNum, "510199909090002");
	strcpy(pc->data[pc->sz].condition, "未取");
	pc->sz++;
	//2
	strcpy(pc->data[pc->sz].bagFlight, "002");
	strcpy(pc->data[pc->sz].bagNum, "NI7755");
	strcpy(pc->data[pc->sz].name, "李丽");
	strcpy(pc->data[pc->sz].idNum, "510200012290001");
	strcpy(pc->data[pc->sz].condition, "已取");
	pc->sz++;
	//3
	strcpy(pc->data[pc->sz].bagFlight, "003");
	strcpy(pc->data[pc->sz].bagNum, "MQ9090");
	strcpy(pc->data[pc->sz].name, "王一");
	strcpy(pc->data[pc->sz].idNum, "510198810090003");
	strcpy(pc->data[pc->sz].condition, "未取");
	pc->sz++;
	//4
	strcpy(pc->data[pc->sz].bagFlight, "004");
	strcpy(pc->data[pc->sz].bagNum, "BU8080");
	strcpy(pc->data[pc->sz].name, "赵山");
	strcpy(pc->data[pc->sz].idNum, "610197708080022");
	strcpy(pc->data[pc->sz].condition, "未到达");
	pc->sz++;
}
//打印
void ShowBaggage(const Baggage* pc, int i)
{
	printf("%-10s %-10s %-5s %-15s %-30s\n", "行李编号","行李航班号", "姓名", "身份证号", "行李状态");

	printf("%-10s %-10s %-5s %-15s %-30s\n",
		pc->data[i].bagNum, pc->data[i].bagFlight, pc->data[i].name, pc->data[i].idNum, pc->data[i].condition);
}

void judge(Baggage* pc)
{
	printf("请输入你的身份证号:\n");
	char idNum[MAXSIZE];
	scanf("%s", idNum);
	int i = 0;
	for (i = 0; i < pc->sz; i++)
	{
		if (strcmp(idNum, pc->data[i].idNum) == 0)
		{
			break;
		}
	}
	if (i < pc->sz)
	{
		if (strcmp(pc->data[i].condition, "未取") == 0)
		{
			strcpy(pc->data[i].condition,"已取");
		}
		ShowBaggage(pc, i);
	}
	else
	{
		printf("输入错误未查询到您的行李，请重新输入：\n");
	}
}
int main()
{
	int input = 1;
	Baggage bag;
	InitBaggage(&bag);

	printf("***欢迎来到行李自提处***\n");
	printf("\n");
	while(input)
	{
		judge(&bag);
	}
	

	return 0;
}